{{#extends @html/widgets/node_widget.html}}

{{:widget_div_name}}tags{{/:widget_div_name}}

{{:widget_title}}{{?widget.title}}{{widget.title}}{{?:}}Темы{{/?}}{{/:widget_title}}

{{:widget_body}}
	{{?widget.content.tags}}
	<div class="body-">
		<ul class="tags-">
		{{!for widget.content.tags do=@:tag}}{{:tag}}
			<li class="t{{*weight | sprintf '%02d'}}-"><a href="{{/}}showfeed?tag={{*name}}">{{*name}}</a>{{?!For.last}}, {{/?}}</li>
		{{/:tag}}
		</ul>
	</div>
	{{/?}}
{{/:widget_body}}

{{:settings}}
	<div class="popup-widgets" id="settings_container">
		<form action="" id="settingsform">
		<input type="hidden" name="widget_id" value="{{settings.id}}" id="widget_id" />
		<h2 class="title-">Облако тегов</h2>
		<div class="content-" style="height: 400px; overflow: auto;">
			<fieldset class="fieldset- header- text-">
				<label>Заголовок</label>
				<input type="text" name="title" value="{{settings.title}}" />
				<div class="comment-">Не более 100 символов</div>
			</fieldset>
			<fieldset class="fieldset- header- text-">
				<label>Брать теги:</label>
				<input type="radio" style="display:inline;width: 24px;" id="from_node" name="from" value="node"{{?'node'==settings.from || !settings.from}} checked="checked"{{/?}} />
				<label for="from_node" style="display:inline; margin-left: 24px;"> всего узла</label><br />
				<input type="radio" style="display:inline;width: 24px;" id="from_community" name="from" value="community"{{?'community'==settings.from}} checked="checked"{{/?}} /> 
				<label for="from_community" style="display:inline; margin-left: 24px;">только из сообществ</label><br />
				{{!for settings.community do=@:community}}
			</fieldset>
		</div>
		{{@:settingsbutton}}
		</form>
		<script>
		jQuery("#from_node").bind("click", function(){
			setCheckBoxRights()
		});
		jQuery("#from_community").bind("click", function(){
			setCheckBoxRights()
		});
		jQuery().ready( function(){
			setCheckBoxRights();
		});
	
		function setCheckBoxRights() {
			var from_node = jQuery("#from_node").get(0).checked;
			jQuery("#settings_container").find("input.commcheck-").each(function(){
				if ( from_node ) {
					this.disabled = true;
					this.checked = false;
				} else {
					this.disabled = false;
				}
			});
		}
	
		function toggleGroup( parentItem, groupName ) {
			var setCheck = parentItem.checked;
			jQuery("#settings_container").find("input." + groupName).each(function(){
				this.checked = setCheck;
			});
		}
	
		function testCheckParent( childItem, parentOID, groupName ) {
			var setCheck = childItem.checked;
		
			if ( setCheck ) {
				jQuery("#community" + parentOID).get(0).checked = true;
			} else {
				var needClean = true;
				jQuery("#settings_container").find("input." + groupName).each(function(){
					if ( this.checked ) {
						needClean = false;
					}
				});
			
				if ( needClean ) {
					jQuery("#community" + parentOID).get(0).checked = false;
				}
			}
		}
		</script>
	</div>
{{/:settings}}
